package com.example.dllo.exe.giftspeak;

import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.dllo.exe.R;
import com.example.dllo.exe.bean.SouSuoGongLueDanPinBean;
import com.example.dllo.exe.fengzhuang.NetTool;
import com.example.dllo.exe.fenlei.xuanlishenqi.XuanLiShenQiAty;
import com.example.dllo.exe.main.BaseAty;
import com.example.dllo.exe.fengzhuang.DBValue;

/**
 * code is far away from bug with the animal protecting
 * <p/>
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃永无BUG！  凯哥 祝你一路顺风
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 */
public class GiftSpeakSouSuoAty extends BaseAty implements View.OnClickListener, TextWatcher {
    private RecyclerView recyclerViewsousuodanpingonglue;
    private GiftSouSuoRvAdapter giftSouSuoRvAdapter;
    private ImageView imageViewsousuodanpingonglue;
    private LinearLayout llsousuogonglue;
    private EditText editTextSS;

    @Override
    protected int setLayout() {
        return R.layout.giftspeaksousuolayout;
    }

    @Override
    protected void initView() {
        recyclerViewsousuodanpingonglue = bindView(R.id.sousuodanpingonglue_rv);
        imageViewsousuodanpingonglue = bindView(R.id.image_sousuodanpingonglue);
        editTextSS = bindView(R.id.EditText_SS);
        llsousuogonglue = bindView(R.id.ll_sousuodanpingonglue);
    }

    @Override
    protected void initData() {
        GridLayoutManager manager = new GridLayoutManager(getApplicationContext(), 3);
        giftSouSuoRvAdapter = new GiftSouSuoRvAdapter(getApplicationContext());
        recyclerViewsousuodanpingonglue.setLayoutManager(manager);
        NetTool netTool = new NetTool();
        netTool.getNetData(DBValue.GIFTSPEAK_GONGLUEDANPINSOUSUO, SouSuoGongLueDanPinBean.class, new NetTool.NetListener<SouSuoGongLueDanPinBean>() {
            @Override
            public void onSuccess(SouSuoGongLueDanPinBean souSuoGongLueDanPinBean) {
                giftSouSuoRvAdapter.setSuoGongLueDanPinBean(souSuoGongLueDanPinBean);
                recyclerViewsousuodanpingonglue.setAdapter(giftSouSuoRvAdapter);
            }

            @Override
            public void onError(String errorMsg) {

            }
        });

        imageViewsousuodanpingonglue.setOnClickListener(this);
        editTextSS.addTextChangedListener(this);
        llsousuogonglue.setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.image_sousuodanpingonglue:
                finish();

                break;
            case R.id.ll_sousuodanpingonglue:
                Intent intent = new Intent(GiftSpeakSouSuoAty.this, XuanLiShenQiAty.class);
                startActivity(intent);
                break;
        }

    }

    //EditText改变之前
    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    //EditText改变的时候
    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    //EditText改变之后
    @Override
    public void afterTextChanged(Editable editable) {
          if (editTextSS.length()>0){

          }
    }
}
